#ifndef _SCALAR_FIELD_H_

#define _SCALAR_FIELD_H_

#include "field.h"

namespace pavan {

template <class itype , class dtype , int dim>
  class scalarPointField : public field<itype,dtype,dim> {

  public:
    scalarPointField( grid<itype,dtype,dim> &G , const char *name ) :
      field<itype,dtype,dim>( G , name ) {
      /// Get access to all blocks of the grid
      DECL_BLOCK_VEC( itype , dtype , dim ) &blks = 
        const_cast<DECL_BLOCK_VEC( itype , dtype , dim ) &>(G.getAllBlocks());
      
      /// Allocate room for the total number of blocks in the grid
      std::cout << "Allocating scalar variable " << this->_name
                << " with " << blks.size() << " blocks\n";
      _data.resize( blks.size() );
      /// Within each block allocate room for variable storage
      for( itype iblk = 0 ; iblk < _data.size() ; ++iblk ) {
        _data[iblk].resize( blks[iblk].getExtent() );
        std::cout << blks[iblk].getExtent() << "\n";
      }
    }
    
     grid<itype,dtype,dim> &mesh() {
       return const_cast<grid<itype,dtype,dim> &>(*(this->_grid));
     }
       
    const DECL_SCALAR_DATA( dtype , dim ) &data() {
      return
        reinterpret_cast
          < 
            const DECL_SCALAR_DATA( dtype , dim ) & 
          >(_data);
    }

  private:
    DECL_SCALAR_DATA( dtype , dim ) _data;

};

}

#endif

